package com.zhf.rabbitmq.workqueue;

import com.google.gson.Gson;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.zhf.rabbitmq.utils.RabbitConstant;
import com.zhf.rabbitmq.utils.RabbitUtil;


/**
 * @author: 曾鸿发
 * @create: 2022-01-08 18:27
 * @description：
 **/
public class OrderSystem {

    public static void main(String[] args) throws Exception{
        Connection connection = RabbitUtil.getConnection();
        Channel channel = connection.createChannel();
        channel.queueDeclare(RabbitConstant.QUEUES_SMS, false, false, false, null);
        for(int i = 1; i <= 100; i++){
            SMS sms = new SMS("乘客" + i, "13900000", "您的车票已预订成功");
            String jsonSMS = new Gson().toJson(sms);
            channel.basicPublish("", RabbitConstant.QUEUES_SMS, null, jsonSMS.getBytes());
        }
        System.out.println("发送数据成功");
        channel.close();
        connection.close();

    }
}
